package cn.itcast.activemq.customer.smsConsumer;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

@Service("smsConsumer")
public class SmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {

		MapMessage mapmessage = (MapMessage) message;
		// String result = SmsUtils.sendSmsByHTTP(model.getTelephone(), rnm);
		String result = "000/XXXX";
		if (result.startsWith("000")) {
			// 短信发送成功
			try {
				System.out.println("短信发送成功，手机号"+mapmessage.getString("telephone")+"信息为:"+mapmessage.getString("mrg"));
			} catch (JMSException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} else {

			throw new RuntimeException("短信发送失败，错误码" + result);
		}

	}

}
